<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>有线网络配置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../../css/public.css" media="all" />
</head>

<body>
    <br>
    <br>
    <form class="layui-form" action="" lay-filter="networkform">
        <div class="layui-form-item">
            <label class="layui-form-label">DHCP开关</label>
            <div class="layui-input-block">
                <input type="checkbox" name="DHCP" lay-skin="switch" lay-text="On|Off">
            </div>
        </div>

        <div class="layui-form-item layui-col-md3">
            <label class="layui-form-label">IP</label>
            <div class="layui-input-block">
                <input type="text" name="IP" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-col-md3">
            <label class="layui-form-label">Netmask</label>
            <div class="layui-input-block">
                <input type="text" name="Netmask" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-col-md3">
            <label class="layui-form-label">Broadcast</label>
            <div class="layui-input-block">
                <input type="text" name="Broadcast" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <br>
        <br>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="update">获取更新</button>
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="enter">立即提交</button>
            </div>
        </div>
    </form>


    <script type="text/javascript" src="../../layui/layui.js"></script>
    <script type="text/javascript" src="../../js/cache.js"></script>
    <script type="text/javascript">
        layui.use(['element', 'form', 'jquery'], function() {

            var $ = layui.jquery;
            var form = layui.form

            //监听提交
            form.on('submit(update)', function() {
                $.ajax({
                    url: "/api/v1/serial",
                    type: "Get",
                    dataType: "json",
                    success: function(data) {
                        console.log(data);
                        console.log(data.Data.BaudRate);
                        //var select1 = 'dd[lay-value=' + data.Data.list[2].cnt + ']';
                        var select1 = 'dd[option-value=' + 2400 + ']';
                        $('#BaudRate').siblings("div.layui-form-select").find('dl').find(select1).click();
                    },
                    error: function(data) {
                        console.log("错误")
                    }
                });
            });

            form.on('submit(enter)', function(data) {
                console.log(JSON.stringify(data.field))
                    //return false;
                $.ajax({
                    url: "/api/v1/network",
                    data: JSON.stringify(data.field),
                    type: "Post",
                    dataType: "json",
                    success: function(data) {
                        console.log(data);

                    },
                    error: function(data) {
                        console.log("错误")
                    }
                });
            });

        });
    </script>

</body>

</html>